//
// NeL - bindings
// Copyright (C) 2010 Naush
//
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as
//published by the Free Software Foundation, either version 3 of the
//License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Affero General Public License for more details.
//
//You should have received a copy of the GNU Affero General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.ryzom.nel.misc;

public class IGameDevice {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public IGameDevice(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(IGameDevice obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nelmiscJNI.delete_IGameDevice(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public CGameDeviceDesc getDescription() {
    return new CGameDeviceDesc(nelmiscJNI.IGameDevice_getDescription(swigCPtr, this), false);
  }

  public long getNumButtons() {
    return nelmiscJNI.IGameDevice_getNumButtons(swigCPtr, this);
  }

  public boolean hasAxis(IGameDevice.TAxis axis) {
    return nelmiscJNI.IGameDevice_hasAxis(swigCPtr, this, axis.swigValue());
  }

  public long getNumSliders() {
    return nelmiscJNI.IGameDevice_getNumSliders(swigCPtr, this);
  }

  public long getNumPOV() {
    return nelmiscJNI.IGameDevice_getNumPOV(swigCPtr, this);
  }

  public String getButtonName(long index) {
    return nelmiscJNI.IGameDevice_getButtonName(swigCPtr, this, index);
  }

  public String getAxisName(IGameDevice.TAxis axis) {
    return nelmiscJNI.IGameDevice_getAxisName(swigCPtr, this, axis.swigValue());
  }

  public String getSliderName(long index) {
    return nelmiscJNI.IGameDevice_getSliderName(swigCPtr, this, index);
  }

  public String getPOVName(long index) {
    return nelmiscJNI.IGameDevice_getPOVName(swigCPtr, this, index);
  }

  public boolean getButtonState(long index) {
    return nelmiscJNI.IGameDevice_getButtonState(swigCPtr, this, index);
  }

  public float getAxisValue(IGameDevice.TAxis axis) {
    return nelmiscJNI.IGameDevice_getAxisValue(swigCPtr, this, axis.swigValue());
  }

  public float getSliderPos(long index) {
    return nelmiscJNI.IGameDevice_getSliderPos(swigCPtr, this, index);
  }

  public float getPOVAngle(long index) {
    return nelmiscJNI.IGameDevice_getPOVAngle(swigCPtr, this, index);
  }

  public final static class TAxis {
    public final static TAxis XAxis = new TAxis("XAxis", nelmiscJNI.IGameDevice_XAxis_get());
    public final static TAxis YAxis = new TAxis("YAxis");
    public final static TAxis ZAxis = new TAxis("ZAxis");
    public final static TAxis RXAxis = new TAxis("RXAxis");
    public final static TAxis RYAxis = new TAxis("RYAxis");
    public final static TAxis RZAxis = new TAxis("RZAxis");
    public final static TAxis MaxNumAxis = new TAxis("MaxNumAxis");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TAxis swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TAxis.class + " with value " + swigValue);
    }

    private TAxis(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TAxis(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TAxis(String swigName, TAxis swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TAxis[] swigValues = { XAxis, YAxis, ZAxis, RXAxis, RYAxis, RZAxis, MaxNumAxis };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
